package com.example.androidpattern.observer.classes;

import android.util.Log;

import java.util.Observable;
import java.util.Observer;

/**
 * @ClassName: SystemObserver3D$
 * @Description: 观察者A
 * @Author: xinya
 * @CreateDate: 2020/11/10$ 15:39$
 * @UpdateRemark: 更新内容
 * @Version: 1.0
 */
public class SystemObserverA implements Observer {
    private static final String TAG = "SystemObserverA";

    public void registerSubject(Observable observable) {
        observable.addObserver(this);
    }

    public void unregisterSubject(Observable observable) {
        observable.deleteObserver(this);
    }

    @Override
    public void update(Observable o, Object arg) {
        if (o instanceof SystemSubject2D) {
            Log.d(TAG, "update: SystemSubject2D -> " + (String) arg);
        } else if (o instanceof SystemSubject3D) {
            Log.d(TAG, "update: SystemSubject3D -> " + (String) arg);
        }
    }
}
